package cn.com.scitc.dao;

import cn.com.scitc.mapper.StudentMapper;
import cn.com.scitc.model.Student;
import org.apache.ibatis.session.SqlSession;

public class StudentDao {

//    public Student findById(Integer id){
//        try (SqlSession sqlSession = MybatisUtil.getSqlSession()){
//            StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
//            return studentMapper.selectByPrimaryKey(id);
//        }
//    }

    public int inserStudent(Student id){
        try (SqlSession sqlSession = MybatisUtil.getSqlSession()){
            StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
            return studentMapper.insert(id);
        }
    }

    public int deletStudent(Integer id){
        try (SqlSession sqlSession = MybatisUtil.getSqlSession()){
            StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
            return studentMapper.deleteByPrimaryKey(id);
        }
    }

    public int updateStudent(Student id){
        try (SqlSession sqlSession = MybatisUtil.getSqlSession()){
            StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
            return studentMapper.updateByPrimaryKey(id);

        }
    }
}
